"""
Case Type   : 服务端工具
Case Name   : gs_dumpall工具指定verbose模式，但不指定数据库
Create At   : 2021/01/15
Owner       : opentestcase002
Description :
    gs_dumpall工具指定verbose模式，但不指定数据库
Expect      :
    导出失败
History     :
    modified by opentestcase016 2023/09/7 代码变更环境变量中增加了PGPORT,需优化用例
"""
import unittest
from yat.test import Node
from yat.test import macro
from testcase.utils.Constant import Constant
from testcase.utils.Logger import Logger

LOG = Logger()


class Tools(unittest.TestCase):
    def setUp(self):
        LOG.info('---Opengauss_Function_Tools_gs_dumpall_Case0005start---')
        self.dbuser_node = Node('dbuser')
        self.Constant = Constant()

    def test_server_tools1(self):
        LOG.info('-----指定verbose模式，但不指定数据库------')
        cmd_list = ['-v', '--verbose']
        for cmd in cmd_list:
            check_cmd1 = f'''source {macro.DB_ENV_PATH};
                        unset PGPORT;
                        gs_dumpall {cmd}'''
            LOG.info(check_cmd1)
            msg1 = self.dbuser_node.sh(check_cmd1).result()
            LOG.info(msg1)
            self.assertIn('failed', msg1)

    def tearDown(self):
        LOG.info('--------------无需清理环境-------------------')
        LOG.info('--Opengauss_Function_Tools_gs_dumpall_Case0005finish--')

